# encoding=utf-8
# author:梁子龙
from datetime import datetime

from comment.modules import db


class Article(db.Model):
    __tablename__ = 't_article'
    id = db.Column(db.Integer, primary_key=True, autoincrement=True)
    article_user_id = db.Column(db.String(64), comment='那个用户的文章')
    article_title = db.Column(db.String(128), comment='文章标题')
    article_content = db.Column(db.Text, comment='文章内容')
    article_view_count = db.Column(db.Integer, comment='文章浏览次数')
    article_comment_count = db.Column(db.Integer, comment='文章评论次数')
    article_like_count = db.Column(db.Integer, comment='文章喜欢数量')

    article_create_time = db.Column(db.DateTime, default=datetime.now(), comment='创建时间')
    article_update_time = db.Column(db.DateTime, default=datetime.now(), onupdate=datetime.now(), comment='更新时间')

    def __repr__(self):
        return f"这是{self.article_user_id}用户上传文章的标题{self.article_title}"


class Tag(db.Model):  # 文章的标签
    __tablename__ = 't_tag'
    tag_id = db.Column(db.Integer, primary_key=True, autoincrement=True)
    tag_name = db.Column(db.String(64), comment='标签名字')
    tag_description = db.Column(db.String(128), comment='标签描述')

    def __repr__(self):
        return f"这是标签的id:{self.tag_id},标签的姓名{self.tag_name}"


class Menu(db.Model):  # 首页的菜单
    __tablename__ = 't_menu'
    id = db.Column(db.Integer, primary_key=True, autoincrement=True)
    menu_name = db.Column(db.String(6128), comment='菜单姓名')
    menu_url = db.Column(db.String(128), comment='菜单链接')
    menu_icon = db.Column(db.String(128), comment='菜单头像')
    menu_level = db.Column(db.String(128), comment='菜单排序')
    menu_order = db.Column(db.String(30), comment='菜单排序')
    create_time = db.Column(db.DateTime, default=datetime.now(), comment='创建时间')
    update_time = db.Column(db.DateTime, default=datetime.now(), onupdate=datetime.now(), comment='更新时间')

    def __repr__(self):
        return f"当前的菜单链接{self.menu_url},当前的菜单名字{self.menu_name}"


class Category(db.Model):
    __tablename__ = 't_category'
    id = db.Column(db.Integer, primary_key=True, autoincrement=True)
    category_pid = db.Column(db.Integer, comment='分类id')
    category_name = db.Column(db.String(128), comment='分类名称')
    category_description = db.Column(db.String(255), comment='分类描述')
    category_order = db.Column(db.Integer, comment='分类排序')
    category_icon = db.Column(db.String(255), comment='分类头像')

    category_create_time = db.Column(db.DateTime, default=datetime.now(), comment='创建时间')
    category_update_time = db.Column(db.DateTime, default=datetime.now(), onupdate=datetime.now(), comment='更新时间')

    def __repr__(self):
        return f"当前的专案号{self.id},当前的专案名{self.catagory_name}"


class Comment(db.Model):
    __tablename__ = 't_comment'
    id = db.Column(db.Integer, primary_key=True, autoincrement=True)
    comment_pid = db.Column(db.String(64), comment='订单号')
    comment_pname = db.Column(db.String(128), comment='订单名')
    comment_author_id = db.Column(db.String(30), comment='订单状态')
    comment_author_name = db.Column(db.String(30), comment='订单状态')
    comment_author_email = db.Column(db.String(30), comment='订单状态')
    comment_author_url = db.Column(db.String(30), comment='订单状态')
    comment_author_avatar = db.Column(db.String(30), comment='订单状态')
    comment_content = db.Column(db.String(30), comment='订单状态')
    comment_create_time = db.Column(db.DateTime, default=datetime.now, comment='创建时间')
    comment_role = db.Column(db.String(30), comment='订单状态')
    comment_user_id = db.Column(db.String(30), comment='订单状态')

    create_time = db.Column(db.DateTime, default=datetime.now(), comment='创建时间')
    update_time = db.Column(db.DateTime, default=datetime.now(), onupdate=datetime.now(), comment='更新时间')

    def __repr__(self):
        return f"当前的专案号{self.id},当前的分类姓名{self.category_name}"
